<template>
  <div class="app-container">
    <div style="font-size: 14px">
      <div v-for="(item, index) in categories" :key="index">
        <span style="font-size: 12px; color: #606266">{{ item.name }}:</span>
        <el-radio-group
          v-model="queryParams[item.key]"
          style="margin: 10px 10px"
          size="mini"
        >
          <el-radio-button
            v-for="(i, ind) in item.tags"
            :key="ind"
            :label="i.value"
            >{{ i.name }}</el-radio-button
          >
        </el-radio-group>
      </div>
    </div>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="职位ID" prop="qdkbId">
        <el-input
          type="number"
          v-model="queryParams.qdkbId"
          placeholder="请输入主键，唯一标识职位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="职位名称" prop="positionName">
        <el-input
          v-model="queryParams.positionName"
          placeholder="请输入职位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="品牌名称" prop="brandName">
        <el-input
          v-model="queryParams.brandName"
          placeholder="请输入品牌名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="职位行业" prop="industry">
        <el-cascader
          clearable
          filterable
          :props="{
            emitPath: false,
          }"
          :show-all-levels="false"
          v-model="queryParams.industry"
          :options="industrys"
        ></el-cascader>
      </el-form-item>
      <el-form-item label="岗位城市" prop="jobCity">
        <el-cascader
          clearable
          filterable
          :props="{
            emitPath: false,
          }"
          :show-all-levels="false"
          v-model="queryParams.jobCity"
          :options="regionData"
        ></el-cascader>
      </el-form-item>
      <el-form-item label="销售城市" prop="salesCity">
        <el-cascader
          clearable
          filterable
          :props="{
            emitPath: false,
          }"
          :show-all-levels="false"
          v-model="queryParams.salesCity"
          :options="regionData"
        ></el-cascader>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:qdkb:add']"
          >新增</el-button
        >
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:qdkb:exportTwo']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <div>
      <el-radio-group
        v-model="queryParams.isFull"
        style="margin: 10px 0"
        size="mini"
        @change="listTab()"
      >
        <el-radio-button :label="null">全部</el-radio-button>
        <el-radio-button label="N">未抢满</el-radio-button>
        <el-radio-button label="Y">已抢满</el-radio-button>
      </el-radio-group>
    </div>
    <!-- <div>
        <el-radio-group
          v-model="queryParams.interviewdeadline"
          style="margin: 10px 0"
          size="mini"
          @change="listTab()"
        >
          <el-radio-button :label="null">全部</el-radio-button>
          <el-radio-button label="N">面试未截至</el-radio-button>
          <el-radio-button label="Y">面试已截至</el-radio-button>
        </el-radio-group>
      </div> -->
    <el-table
      v-loading="loading"
      :data="qdkbList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="公司名称" align="center" width="270">
        <template slot-scope="scope">
          <div class="company" @click="seeqdkb(scope.row.qdkbId)">
            <div class="left">
              <img
                :src="scope.row.picUrl ? baseUrl + scope.row.picUrl : c"
                :width="80"
                :height="80"
                alt="职位图片"
              />
              <div class="pro">
                {{ scope.row.combinedInfo.employmentType }}
              </div>
              <div class="id">{{ scope.row.combinedInfo.id }}</div>
            </div>
            <div class="right">
              <div class="titlename">
                {{ scope.row.combinedInfo.positionName }}
              </div>
              <div class="brand">
                {{ scope.row.combinedInfo.brandName }}
              </div>
              <div>
                <el-tag type="danger" v-if="scope.row.interviewdeadline == 'Y'"
                  >面试已截至</el-tag
                >
              </div>
              <div>
                <el-tag type="info" v-if="scope.row.isFull == 'Y'"
                  >已抢满</el-tag
                >
              </div>
            </div>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="结算规则" width="500">
        <template slot-scope="scope">
          <div class="rule">
            <template v-for="(item, index) in scope.row.rebateInfoArray">
              <div v-if="item.value" :key="index" class="ellipsis">
                <span>{{ item.label }}：</span>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.value"
                  placement="top-start"
                >
                  <span class="val">{{ item.value }}</span>
                </el-tooltip>
              </div>
            </template>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="更新时间"
        align="center"
        prop="updateTime"
        width="200"
      />
      <el-table-column
        label="负责人"
        align="center"
        prop="positionResponsiblePerson"
      />
      <el-table-column
        label="联系PM"
        align="center"
        prop="phonenumber"
        width="200"
      />
      <el-table-column
        label="需求人数"
        align="center"
        prop="requiredQuantity"
      />
      <el-table-column
        label="已抢单TL数量"
        align="center"
        prop="recommendedOfficerCount"
      />
      <el-table-column
        label="职位面试城市"
        align="center"
        prop="interviewCity"
      />
      <el-table-column
        label="操作"
        fixed="right"
        align="center"
        width="200"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-bell"
            @click="
              handleUpdateYN(scope.row.isFull, scope.row.qdkbId, 'isFull')
            "
            v-hasPermi="['system:qdkb:edit']"
            >{{
              scope.row.isFull == "N" ? "设置已抢满" : "设置未抢满"
            }}</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-release"
            @click="
              handleUpdateYN(
                scope.row.interviewdeadline,
                scope.row.qdkbId,
                'interviewdeadline'
              )
            "
            v-hasPermi="['system:qdkb:edit']"
            >{{
              scope.row.interviewdeadline == "N" ? "面试截至" : "恢复面试"
            }}</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:qdkb:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-release"
            v-hasPermi="['system:pq:pmadd']"
            @click="handleAddOrUpdate(scope.row.qdkbId)"
            >职位排期</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改岗位信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="140px"
        label-position="left"
      >
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="职位名称" prop="positionName">
              <el-input
                v-model="form.positionName"
                placeholder="请输入职位名称"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="品牌名称" prop="brandName">
              <el-input v-model="form.brandName" placeholder="请输入品牌名称" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="图片" prop="picUrl">
              <image-upload v-model="form.picUrl" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="职位标签" prop="fn">
              <el-select v-model="form.positionLabel">
                <el-option
                  v-for="(item, index) in categories[1].tags.filter(
                    (v) => v.name != '全部'
                  )"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="职位职能" prop="fn">
              <el-select v-model="form.fn">
                <el-option
                  v-for="(item, index) in categories[3].tags.filter(
                    (v) => v.name != '全部'
                  )"
                  :key="index"
                  :label="item.name"
                  :value="item.name"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="职位行业" prop="industryList">
              <el-cascader
                filterable
                :show-all-levels="false"
                v-model="form.industryList"
                :options="industrys"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="用工类型" prop="employmentType">
              <el-select v-model="form.employmentType">
                <el-option
                  v-for="(item, index) in categories[2].tags.filter(
                    (v) => v.name != '全部'
                  )"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="返费类别" prop="rebateType">
              <el-select
                v-model="form.rebateType"
                @change="ruleset()"
                :disabled="form.qdkbId"
              >
                <el-option
                  v-for="(item, index) in categories[0].tags.filter(
                    (v) => v.name != '全部'
                  )"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="返费价格" prop="rebatePrice">
              <el-input
                placeholder="请输入返费价格"
                type="number"
                v-model="form.rebatePrice"
              >
                <template slot="append">{{
                  cateTab[form.rebateType]
                }}</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="返费规则生效时间" prop="effectiveDate">
              <el-date-picker
                clearable
                v-model="form.effectiveDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择返费规则生效时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="12" v-if="form.rebateType == '一次性返费'">
            <el-form-item label="返费规则" prop="rebateRule">
              <el-input
                v-model="form.rebateRule"
                placeholder="请输入返费规则"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.rebateType == '一次性返费'">
            <el-form-item label="价格规则" prop="priceRule">
              <el-input v-model="form.priceRule" placeholder="请输入价格规则" />
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="form.rebateType == '一次性返费'"> </el-col>
          <el-col
            :span="12"
            v-if="
              form.rebateType == '一次性返费' || form.rebateType == '月返费'
            "
          >
            <el-form-item label="返费条件" prop="rebateCondition">
              <el-input
                v-model="form.rebateCondition"
                placeholder="请输入返费条件"
              />
            </el-form-item>
          </el-col>

          <el-col :span="24" v-if="form.rebateType != '一次性返费'">
            <el-form-item label="返费周期(月)" prop="refundPeriod">
              <el-input-number
                v-model="form.refundPeriod"
                :min="1"
                :max="36"
                label="请输入返费周期"
              ></el-input-number>
            </el-form-item>
          </el-col>

          <el-col :span="12" v-if="form.rebateType == '月返费'">
            <el-form-item label="首次返费考勤要求" prop="firstRefund">
              <el-input
                v-model="form.firstRefund"
                placeholder="请输入首次返费最低考勤要求"
              />
            </el-form-item>
          </el-col>
          <el-col
            :span="12"
            v-if="form.rebateType == '日返费' || form.rebateType == '小时返费'"
          >
            <el-form-item label="返费说明" prop="refundExplanation">
              <el-input
                v-model="form.refundExplanation"
                placeholder="请输入返费说明"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24"> </el-col>
          <el-col :span="6">
            <el-form-item label="岗位城市" prop="jobCity">
              <el-cascader
                clearable
                filterable
                :props="{
                  emitPath: false,
                }"
                :show-all-levels="false"
                v-model="form.jobCity"
                :options="regionData"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="销售城市" prop="salesCity">
              <el-cascader
                clearable
                filterable
                :props="{
                  emitPath: false,
                }"
                :show-all-levels="false"
                v-model="form.salesCity"
                :options="regionData"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="职位面试城市" prop="interviewCity">
              <el-cascader
                clearable
                filterable
                :props="{
                  emitPath: false,
                }"
                :show-all-levels="false"
                v-model="form.interviewCity"
                :options="regionData"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="需求人数" prop="requiredQuantity">
              <el-input-number
                v-model="form.requiredQuantity"
                :min="1"
                label="请输入需求人数"
              ></el-input-number>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="工作时间" prop="workDate">
              <el-input v-model="form.workDate" placeholder="请输入工作时间" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="工作地点" prop="workAdress">
              <el-input
                v-model="form.workAdress"
                type="textarea"
                placeholder="请输入内容"
                maxlength="300"
                show-word-limit
              />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="年龄范围" prop="ageRange">
              <el-select v-model="form.ageRange">
                <el-option
                  v-for="(item, index) in ages"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="性别要求" prop="genderRequirement">
              <el-select v-model="form.genderRequirement">
                <el-option
                  v-for="(item, index) in sexs"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="学历要求" prop="educationRequirement">
              <el-select v-model="form.educationRequirement">
                <el-option
                  v-for="(item, index) in educations"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="工作经验要求" prop="experienceRequirement">
              <el-select v-model="form.experienceRequirement">
                <el-option
                  v-for="(item, index) in works"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="面试时间" prop="dateList">
              <el-date-picker
                v-model="form.dateList"
                type="daterange"
                range-separator="至"
                value-format="yyyy-MM-dd"
                start-placeholder="面试开始时间"
                end-placeholder="面试结束时间"
              >
              </el-date-picker>
              <!-- <el-date-picker
                clearable
                v-model="form.interviewStartDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择面试开始时间"
              >
              </el-date-picker> -->
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="面试结束时间" prop="interviewSendDate">
              <el-date-picker
                clearable
                v-model="form.interviewSendDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择面试结束时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col> -->
          <el-col :span="24">
            <el-form-item label="面试地点" prop="interviewAddress">
              <el-input
                v-model="form.interviewAddress"
                type="textarea"
                placeholder="请输入内容"
                maxlength="300"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职位负责人" prop="positionResponsiblePerson">
              <el-input
                :disabled="true"
                v-model="form.positionResponsiblePerson"
                placeholder="请输入职位负责人"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职位参与人" prop="positionParticipants">
              <el-input
                v-model="form.positionParticipants"
                placeholder="请输入职位参与人"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="职位亮点" prop="positionHighlights">
              <el-input
                v-model="form.positionHighlights"
                type="textarea"
                :rows="5"
                placeholder="请输入内容"
                maxlength="300"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="职位描述" prop="positionDescription">
              <el-input
                v-model="form.positionDescription"
                type="textarea"
                :rows="5"
                placeholder="请输入内容"
                maxlength="300"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="沟通要点" prop="communicate">
              <el-input
                v-model="form.communicate"
                type="textarea"
                :rows="5"
                placeholder="请输入内容"
                maxlength="300"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否抢满" prop="isFull">
              <el-radio-group v-model="form.isFull">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否面试截至" prop="interviewdeadline">
              <el-radio-group v-model="form.interviewdeadline">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="基本薪资" prop="baseSalary">
              <el-input
                v-model="form.baseSalary"
                placeholder="请输入基本薪资"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="综合薪资" prop="totalSalary">
              <el-input
                v-model="form.totalSalary"
                placeholder="请输入综合薪资"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24"></el-col>
          <el-col :span="12">
            <el-form-item label="其他构成" prop="salaryComponents">
              <el-input
                v-model="form.salaryComponents"
                placeholder="请输入其他构成"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="薪资备注" prop="salaryNotes">
              <el-input
                v-model="form.salaryNotes"
                type="textarea"
                placeholder="请输入内容"
                maxlength="300"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="提供住宿" prop="hasHousingProvided">
              <el-radio-group v-model="form.hasHousingProvided">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="社保" prop="hasSocialInsurance">
              <el-radio-group v-model="form.hasSocialInsurance">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="商保" prop="hasCommercialInsurance">
              <el-radio-group v-model="form.hasCommercialInsurance">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="公积金" prop="hasHousingFund">
              <el-radio-group v-model="form.hasHousingFund">
                <el-radio
                  v-for="dict in dict.type.sys_yes_no"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog
      :title="title"
      :visible.sync="open1"
      width="500px"
      append-to-body
    >
      <el-form ref="form1" :model="form1" :rules="rules1" label-width="80px">
        <el-form-item label="排期周期" prop="scheduleStartDate">
          <el-date-picker
            v-model="form1.startEnd"
            @change="getWeekDays()"
            :format="form1.scheduleStartDate + '-' + form1.scheduleEndDate"
            value-format="yyyy-MM-dd"
            type="week"
            :picker-options="{ firstDayOfWeek: 1 }"
            placeholder="选择周"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="交付顾问" prop="userIds">
          <el-select
            v-model="form1.userIds"
            filterable
            multiple
            placeholder="请选择"
          >
            <el-option
              v-for="(item, index) in userList"
              :key="index"
              :label="item.userName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>
    <el-drawer
      title="职位信息"
      :visible.sync="open2"
      direction="ltr"
      width="40%"
    >
      <el-form label-position="left" class="demo-table-expand">
        <el-form-item label=""><h3>职位基本信息</h3></el-form-item>
        <div style="border-bottom: 1px solid #e6ebf5">
          <el-row :gutter="10" class="mb8">
            <el-col :span="12"
              ><el-form-item label="职位名称:">
                {{ qdkbData.positionName }}
              </el-form-item></el-col
            >
            <el-col :span="12"
              ><el-form-item label="用工类型:">
                {{ qdkbData.employmentType }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="品牌:">
                {{ qdkbData.brandName }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="需求入职:">
                {{ qdkbData.requiredQuantity }}人
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="职能:">
                {{ qdkbData.fn }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="工作地点:">
                {{ qdkbData.workAdress }}
              </el-form-item></el-col
            >
          </el-row>
        </div>
        <div style="border-bottom: 1px solid #e6ebf5">
          <el-row :gutter="10" class="mb8">
            <el-col :span="12"
              ><el-form-item label="年龄:">
                {{ qdkbData.ageRange || "不限" }}
              </el-form-item></el-col
            >
            <el-col :span="12"
              ><el-form-item label="性别:">
                {{ qdkbData.genderRequirement || "不限" }}
              </el-form-item></el-col
            >
            <el-col :span="12"
              ><el-form-item label="学历:">
                {{ qdkbData.educationRequirement || "不限" }}
              </el-form-item></el-col
            >
            <el-col :span="12"
              ><el-form-item label="工作经验:">
                {{ qdkbData.experienceRequirement || "不限" }}
              </el-form-item></el-col
            >
          </el-row>
        </div>
        <div>
          <el-row :gutter="10" class="mb8">
            <el-col :span="24"
              ><el-form-item label="面试地点:">
                {{ qdkbData.interviewAddress }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="面试时间:">
                {{ qdkbData.interviewStartDate }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="结束时间:">
                {{ qdkbData.interviewSendDate }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="工作时间:">
                {{ qdkbData.workDate }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="职位负责人:">
                {{ qdkbData.positionResponsiblePerson }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="职位负责人电话:">
                {{ qdkbData.phonenumber }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="职位参与人:">
                {{ qdkbData.positionParticipants }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="职位亮点:">
                {{ qdkbData.positionHighlights }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="职位描述:">
                {{ qdkbData.positionDescription }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="沟通要点:">
                {{ qdkbData.communicate }}
              </el-form-item></el-col
            >
          </el-row>
        </div>
        <el-form-item label=""><h3>薪资福利</h3></el-form-item>
        <div>
          <el-row :gutter="10" class="mb8">
            <el-col :span="24"
              ><el-form-item label="基本薪资:">
                {{ qdkbData.baseSalary }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="综合薪资:">
                {{ qdkbData.totalSalary }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="其他构成:">
                {{ qdkbData.salaryComponents }}
              </el-form-item></el-col
            >
            <el-col :span="24"
              ><el-form-item label="薪资备注:">
                {{ qdkbData.salaryNotes }}
              </el-form-item></el-col
            >
            <el-col :span="6"
              ><el-form-item label="提供住宿:">
                {{ qdkbData.hasHousingProvided == "Y" ? "是" : "否" }}
              </el-form-item></el-col
            >
            <el-col :span="6"
              ><el-form-item label="社保:">
                {{ qdkbData.hasSocialInsurance == "Y" ? "是" : "否" }}
              </el-form-item></el-col
            >
            <el-col :span="6"
              ><el-form-item label="商保:">
                {{ qdkbData.hasCommercialInsurance == "Y" ? "是" : "否" }}
              </el-form-item></el-col
            >
            <el-col :span="6"
              ><el-form-item label="公积金:">
                {{ qdkbData.hasHousingFund == "Y" ? "是" : "否" }}
              </el-form-item></el-col
            >
          </el-row>
        </div>
      </el-form>
    </el-drawer>
  </div>
</template>

<script>
import {
  listQdkbTwo,
  getQdkb,
  delQdkb,
  addQdkb,
  updateQdkb,
} from "@/api/system/qdkb";
import {
  categories,
  industrys,
  workDates,
  sexs,
  educations,
  works,
  ages,
  cateTab,
} from "@/utils/data.js"; // 根据实际路径调整
import { regionData } from "@/utils/address.js";
import { listPqpmSchedule, pmScheduleAdd } from "@/api/system/pq";
import dayjs from "dayjs";
import c from "@/assets/c.jpg";
export default {
  name: "Qdkb",
  dicts: ["sys_yes_no", "sys_user_sex"],
  data() {
    return {
      c,
      baseUrl: process.env.VUE_APP_BASE_API,
      categories,
      regionData,
      industrys,
      workDates,
      sexs,
      educations,
      works,
      ages,
      cateTab,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位信息表格数据
      qdkbList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      open2: false,
      qdkbData: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        qdkbId: null,
        positionName: null,
        brandName: null,
        rebateType: null,
        positionLabel: null,
        fn: null,
        parentIndustry: null,
        industry: null,
        jobCity: null,
        salesCity: null,
        employmentType: null,
        isFull: null,
        interviewdeadline: null,
      },
      // 表单参数
      form: {},
      form1: {},
      qdkbId: "",
      userList: [],
      mapOrderIds: {},
      qdkbData: [],
      rules1: {
        scheduleStartDate: [
          { required: true, message: "排期开始数据不能为空", trigger: "blur" },
        ],
        userIds: [
          { required: true, message: "用户组不能为空", trigger: "change" },
        ],
      },
      // 表单校验
      rules: {
        positionName: [
          { required: true, message: "职位名称不能为空", trigger: "blur" },
        ],
        brandName: [
          { required: true, message: "品牌名称不能为空", trigger: "blur" },
        ],
        rebateType: [
          { required: true, message: "返费类别不能为空", trigger: "blur" },
        ],
        positionLabel: [
          { required: true, message: "职位标签不能为空", trigger: "change" },
        ],
        fn: [{ required: true, message: "职位职能不能为空", trigger: "blur" }],
        industryList: [
          { required: true, message: "职位行业不能为空", trigger: "blur" },
        ],
        industry: [
          { required: true, message: "职位行业不能为空", trigger: "blur" },
        ],
        effectiveDate: [
          {
            required: true,
            message: "返费规则生效时间不能为空",
            trigger: "blur",
          },
        ],
        rebateRule: [
          { required: true, message: "返费规则不能为空", trigger: "blur" },
        ],
        priceRule: [
          { required: true, message: "价格规则不能为空", trigger: "blur" },
        ],
        rebateCondition: [
          { required: true, message: "返费条件不能为空", trigger: "blur" },
        ],
        rebatePrice: [
          { required: true, message: "返费价格不能为空", trigger: "blur" },
        ],
        jobCity: [
          { required: true, message: "岗位城市不能为空", trigger: "blur" },
        ],
        salesCity: [
          { required: true, message: "销售城市不能为空", trigger: "blur" },
        ],
        interviewCity: [
          { required: true, message: "职位面试城市不能为空", trigger: "blur" },
        ],
        employmentType: [
          { required: true, message: "用工类型不能为空", trigger: "change" },
        ],
        workAdress: [
          { required: true, message: "工作地点不能为空", trigger: "blur" },
        ],
        interviewAddress: [
          { required: true, message: "面试地点不能为空", trigger: "blur" },
        ],
        positionResponsiblePerson: [
          { required: true, message: "职位负责人不能为空", trigger: "blur" },
        ],
        dateList: [
          { required: true, message: "面试时间不能为空", trigger: "blur" },
        ],
        firstRefund: [
          {
            required: true,
            message: "首次返费考勤最低要求不能为空",
            trigger: "blur",
          },
        ],
        refundPeriod: [
          { required: true, message: "返费周期不能为空", trigger: "blur" },
        ],
        refundExplanation: [
          { required: true, message: "返费说明不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getWeekDays() {
      this.form1.userIds = [];
      dayjs.extend(require("dayjs/plugin/isoWeek"));

      dayjs.locale("zh-cn"); // 设置中文语言环境（包含周起始日配置）
      if (this.form1.startEnd) {
        const currentDate = dayjs(this.form1.startEnd);
        const monday = currentDate.isoWeekday(1); // 获取当前周的周一（1 表示周一，0 表示周日）
        this.form1.scheduleStartDate = monday
          .subtract(0, "day")
          .format("YYYY-MM-DD");

        this.form1.scheduleEndDate = monday.add(6, "day").format("YYYY-MM-DD");
      } else {
        // 设置周起始日为周一（Day.js 默认周日为一周开始，需调整）
        const currentDate = dayjs();
        const monday = currentDate.isoWeekday(1); // 获取当前周的周一（1 表示周一，0 表示周日）
        console.log(monday.format("YYYY-MM-DD"));
        this.form1.scheduleStartDate = monday
          .add(0, "day")
          .format("YYYY-MM-DD");
        this.form1.scheduleEndDate = monday.add(6, "day").format("YYYY-MM-DD");
        this.form1.startEnd = monday.add(1, "day").format("YYYY-MM-DD");
      }
      const { scheduleStartDate, scheduleEndDate } = this.form1;
      const qdkbId = this.qdkbId;
      const pq = { scheduleStartDate, scheduleEndDate, qdkbId };
      listPqpmSchedule(pq).then((res) => {
        this.form1.userIds = res.userIds;
        this.userList = res.wdqdBos;
        this.userList.forEach((v) => {
          const userId = v.userId;
          const orderId = v.orderId;
          this.mapOrderIds[userId] = orderId;
        });
      });
    },

    reset1() {
      this.form1 = {
        userIds: null,
        scheduleStartDate: null,
        scheduleEndDate: null,
        startEnd: null,
      };
      this.resetForm("form1");
    },

    // 表单重置
    submitForm1() {
      this.$refs["form1"].validate((valid) => {
        if (valid) {
          const orderIds = this.form1.userIds.map((v) => this.mapOrderIds[v]);
          const { scheduleStartDate, scheduleEndDate } = this.form1;
          const orderIdsString = orderIds.join("_");
          const userIdsString = this.form1.userIds.join("_");
          const qdkbId = this.qdkbId;
          pmScheduleAdd({
            scheduleStartDate,
            scheduleEndDate,
            orderIdsString,
            userIdsString,
            qdkbId,
          }).then((response) => {
            this.$modal.msgSuccess("成功");
            this.open1 = false;
            this.getList();
          });
        }
      });
    },
    handleAddOrUpdate(qdkbId) {
      this.reset1();
      this.qdkbId = qdkbId;
      this.getWeekDays();
      this.open1 = true;
    },
    seeqdkb(qdkbId) {
      getQdkb(qdkbId).then((response) => {
        this.qdkbData = response.data;
        this.open1 = true;
      });
    },
    /** 查询岗位信息列表 */
    ruleset() {
      this.form.rebateRule = "";
      this.form.priceRule = "";
      this.form.refundPeriod = 1;
      this.form.rebateCondition = "";
      this.form.rebateRule = "";
      this.form.firstRefund = "";
      this.form.refundExplanation = "";
    },
    getList() {
      this.loading = true;
      listQdkbTwo(this.queryParams).then((response) => {
        this.qdkbList = response.rows;
        this.qdkbList.forEach((row) => {
          row.rebateInfoArray = [
            { label: "返费类别", value: row.rebateType },
            { label: "生效日期", value: row.effectiveDate },
            { label: "返费规则", value: row.rebateRule },
            { label: "价格规则", value: row.priceRule },
            {
              label: "返费周期",
              value:
                row.rebateType != "一次性返费" ? row.refundPeriod + "月" : "",
            },
            {
              label: "返费价格",
              value: row.rebatePrice + cateTab[row.rebateType],
            },
            { label: "返费条件", value: row.rebateCondition },

            { label: "首次返费最低考勤要求", value: row.firstRefund },
            { label: "返费说明", value: row.refundExplanation },
          ];
        });
        this.qdkbList.forEach((row) => {
          row.combinedInfo = {
            id: `ID:${row.qdkbId}`,
            employmentType: row.employmentType,
            positionName: row.positionName,
            brandName: row.brandName,
          };
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    cancel1() {
      this.open1 = false;
      this.reset1();
    },
    // 表单重置
    reset() {
      this.form = {
        qdkbId: null,
        positionName: null,
        brandName: null,
        picUrl: null,
        rebateType: "一次性返费",
        positionLabel: null,
        fn: null,
        parentIndustry: null,
        industry: null,
        effectiveDate: null,
        rebateRule: null,
        priceRule: null,
        rebateCondition: null,
        rebatePrice: null,
        requiredQuantity: 1,
        recommendedOfficerCount: null,
        jobCity: null,
        salesCity: null,
        interviewCity: null,
        employmentType: null,
        ageRange: null,
        workAdress: null,
        workDate: null,
        genderRequirement: null,
        educationRequirement: null,
        experienceRequirement: null,
        interviewAddress: null,
        interviewStartDate: null,
        interviewSendDate: null,
        positionResponsiblePerson: this.$store.state.user.name,
        positionParticipants: null,
        positionHighlights: null,
        positionDescription: null,
        communicate: null,
        isFull: "N",
        interviewdeadline: "N",
        delFlag: null,
        baseSalary: null,
        totalSalary: null,
        salaryComponents: null,
        salaryNotes: null,
        hasHousingProvided: "N",
        hasSocialInsurance: "N",
        hasCommercialInsurance: "N",
        hasHousingFund: "N",
        enterUserId: null,
        createTime: null,
        dateList: null,
        firstRefund: null,
        refundPeriod: 1,
        refundExplanation: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    listTab() {
      this.handleQuery();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.qdkbId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加岗位信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const qdkbId = row.qdkbId || this.ids;
      getQdkb(qdkbId).then((response) => {
        this.form = response.data;
        this.form.industryList = [this.form.parentIndustry, this.form.industry];
        this.$set(this.form, "dateList", [
          this.form.interviewStartDate,
          this.form.interviewSendDate,
        ]);
        this.open = true;
        this.title = "修改岗位信息";
      });
    },
    handleUpdateYN(v, id, key) {
      const data = {};
      data[key] = v == "N" ? "Y" : "N";
      data.qdkbId = id;
      this.$modal
        .confirm("确定设置")
        .then(function () {
          return updateQdkb(data);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("设置成功");
        })
        .catch(() => {});
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.parentIndustry = this.form.industryList[0];
          this.form.industry = this.form.industryList[1];
          this.form.interviewStartDate = this.form.dateList[0];
          this.form.interviewSendDate = this.form.dateList[1];
          if (this.form.qdkbId != null) {
            updateQdkb(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addQdkb(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const qdkbIds = row.qdkbId || this.ids;
      this.$modal
        .confirm('是否确认删除岗位信息编号为"' + qdkbIds + '"的数据项？')
        .then(function () {
          return delQdkb(qdkbIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/qdkb/exportTwo",
        {
          ...this.queryParams,
        },
        `岗位信息_${new Date().getTime()}.xlsx`
      );
    },

    seeqdkb(qdkbId) {
      getQdkb(qdkbId).then((response) => {
        this.qdkbData = response.data;
        this.open2 = true;
      });
    },
  },
};
</script>
